<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>命名路由和命名视图</title>
    <script src="js/vue.js"></script>
    <script src="js/vue-router.js"></script>
</head>
<body>
    <template id="t1">
        <div>
            <h1>热点信息</h1>    
        </div>
    </template>
    <template id="t2">
        <div>
            <h1>推荐信息</h1>    
        </div>
    </template>
    <template id="t3">
        <div>
            <h1>今日新闻</h1>    
        </div>
    </template>
    <div id="app">
        <div>
            <ul>
                <li><router-link :to="{name:'index1'}">首页</router-link></li>
                <li><router-link :to="{name:'news1'}">新闻</router-link></li>
            </ul>
        </div>
       <div>
            <router-view name="first" style="background-color: hotpink;"></router-view>
            <router-view name="second" style="background-color: lawngreen;"></router-view>
       </div>
    </div>
</body>
</html>
<script>
    var vm=new Vue({
        el:'#app',
        router:new VueRouter({
            routes: [
                {
                    path:'/index',
                    name:'index1',
                    components:{
                        first:{
                            template:'#t1'
                        },
                        second:{
                            template:'#t2'
                        }
                    }
                },
                {
                    path:'/news',
                    name:'news1',
                    components:{
                        first:{
                            template:'#t3'
                        }
                    }
                }
            ]
        })
    });
</script>